#include <bits/stdc++.h>
using namespace std;
#define yes cout << "YES" << endl
#define no cout << "NO" << endl
using ll = long long;
struct inf_
{
    string name;
    int score;
} a[1000000];
int cnt = 1;
map<string, int> mp;
string name;
int score;
int opt = 0;
int count1 = 0;
void solve()
{

    cin >> opt;
    if (opt == 1)
    {
        cin >> name >> score;
        if (mp[name])
        {
            a[mp[name]].score = score;
        }
        else
        {
            count1++;
            a[cnt].name = name;
            a[cnt].score = score;
            mp[name] = cnt++;
        }
        cout << "OK" << endl;
    }
    else if (opt == 2)
    {
        cin >> name;
        if (mp[name])
        {
            cout << a[mp[name]].score << endl;
        }
        else
        {
            cout << "Not found" << endl;
        }
    }
    else if (opt == 3)
    {
        cin >> name;
        if (mp[name])
        {
            mp[name] = 0;
            count1--;
            cout << "Deleted successfully" << endl;
        }
        else
        {
            cout << "Not found" << endl;
        }
    }
    else
    {
        cout << count1 << endl;
    }
}
int main()
{
    int t = 1;
    cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}
